package cn.hls.entity;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

/**
 * @fileName: UserRole.java
 * @package: com.bangni.entity
 * @Description: 用户角色关系映射中间实体类
 * @author: yinghui.zhang
 * @email: uuhui@163.com
 * @date: 2015-5-2
 */
@Entity
@Table(name = "T_USER_ROLE")
@SuppressWarnings("serial")
@DynamicInsert
@DynamicUpdate
public class UserRole extends BaseEntity {
	// 角色信息
	private Role role;
	// 用户信息
	private User user;

	@ManyToOne(optional = true)
	@JoinColumn(name = "role_id")
	@NotFound(action = NotFoundAction.IGNORE)
	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	@ManyToOne(optional = true)
	@JoinColumn(name = "user_id")
	@NotFound(action = NotFoundAction.IGNORE)
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
